<template>
  <xtx-step :currStep="currStep" :steps="steps"></xtx-step>
</template>

<script>
export default {
  name: 'order-step',
  props: {
    order: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    currStep () {
      let step = 0
      if (this.order.orderState < 6) {
        step = this.order.orderState
      }
      if (this.order.orderState === 6) {
        step = 1
      }
      return step
    },
    steps () {
      return [
        { title: '提交订单', desc: this.order.createTime },
        { title: '付款成功', desc: this.order.payTime },
        { title: '商品发货', desc: this.order.consignTime },
        { title: '确认收货', desc: this.order.endTime },
        { title: '订单完成', desc: this.order.evaluationTime }
      ]
    }
  }
}
</script>

<style scoped lang='less'>
.order-step {
  width: 100%;
  display: flex;
  user-select: none;
  .item {
    flex: 1;
    text-align: center;
    .step {
      height: 48px;
      position: relative;
      .num {
        width: 48px;
        height: 48px;
        border: 2px solid #e4e4e4;
        border-radius: 50%;
        line-height: 44px;
        font-size: 28px;
        color: #ccc;
        margin: 0 auto;
        position: relative;
        z-index: 1;
        background-color: #fff;
      }
      .line {
        position: absolute;
        top: 23px;
        height: 2px;
        background-color: #e4e4e4;
        width: 50%;
        &-left {
          left: 0;
        }
        &-right {
          left: 50%;
        }
      }
    }
    .title {
      margin-top: 15px;
      color: #999;
    }
    .desc {
      margin-top: 5px;
      color: #999;
      font-size: 12px;
    }
    &.active {
      .step {
        .num {
          border-color: @xtxColor;
          background-color: @xtxColor;
          color: #fff;
        }
        .line {
          background-color: @xtxColor;
        }
      }
      .title {
        color: @xtxColor;
      }
    }
  }
}
</style>
